﻿using System.Web.Mvc;
using MvcApplication.Interface;
using MvcApplication.Entity;
using MvcApplication.Common;

namespace MvcApplication.Controllers
{
    public class FileCacheController : Controller
    {
        IFileCacheService _fileCacheService;

        public FileCacheController(IFileCacheService fileCacheService)
        {
            _fileCacheService = fileCacheService;
        }

        [Permission(Entity.Menu.文件缓存, Entity.PermissionType.删除)]
        public ActionResult ReBuild(DisplayPage cache)
        {
            switch (cache)
            {
                case DisplayPage.首页:
                    _fileCacheService.ReBuildIndex();
                    break;

                case DisplayPage.内容页:
                    _fileCacheService.ReBuildDetail();
                    break;

                case DisplayPage.类目列表页:
                    _fileCacheService.ReBuildCategory();
                    break;

                case DisplayPage.全部:
                    _fileCacheService.ReBuildIndex();
                    _fileCacheService.ReBuildDetail();
                    _fileCacheService.ReBuildCategory();
                    break;
            }
            return Json(true);
        }
    }
}
